package com.chenshu.demo2.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2023-12-23
 * Time：15:16
 */
@RestController
public class Calc {
    @RequestMapping("calc")
    public String  calculate(String num1, int symbol, String num2) {
        int n1 = Integer.parseInt(num1);
        int n2 = Integer.parseInt(num2);
        int ret = 0;
        if (symbol == 1) {
            ret = n1 + n2;
        } else if (symbol == 2) {
            ret = n1 - n2;
        } else if (symbol == 3) {
            ret = n1 * n2;
        } else if (symbol == 4) {
            ret = n1 / n2;
        } else {
            return "出错！";
        }
        return "结果为" + ret;
    }
}
